package com.antd.common.log;

import com.antd.common.log.annotation.SystemLog;
import com.antd.common.log.aspect.SysLogAspect;
import com.antd.common.log.listener.SysLogListener;
import feign.Logger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2020/11/18 18:05
 */
@Configuration
@EnableFeignClients(value = "com.antd.common.log.fegin")
@EnableAsync
@ConditionalOnWebApplication
public class SysLogAutoConfig {

    @Bean
    public SysLogListener logListener(){
        return new SysLogListener();
    }
    @Bean
    public SysLogAspect logAspect(ApplicationEventPublisher publisher){
        return new SysLogAspect(publisher);
    }

    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }
}
